package com.charging.business.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author JerryLu
 * @date 2024/8/16 11:24
 * @description restTemplate模板配置
 */
@Configuration
public class RestClientConfig {
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        // 设置连接超时为5秒(5000毫秒)
        requestFactory.setConnectTimeout(5000);
        // 设置读取超时为5秒(5000毫秒)
        requestFactory.setReadTimeout(5000);
        return new RestTemplate(requestFactory);
    }
}
